<?php namespace App\Models\Phm\Healthtrends;

use App\Models\Phm\ModelPHM;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Validation\ValidationInterface;

class ModelApuBleedPress extends ModelPHM
{
    function __construct(ConnectionInterface $db = null, ValidationInterface $validation = null)
    {
        parent::__construct($db, $validation);
    }

//返回array形式
    public function getModelApuBleedPress()
    {
        //sql语句
        //$sql = "SELECT `DATE_TIME`, `BRK_TEMP1`, `BRK_TEMP2`, `BRK_TEMP3`, `BRK_TEMP4` FROM  `HEALTHTRENDS4WHEEL` /*limit 0,100000*/ ;";
        $sql = "SELECT `DATE_TIME`, `BRK_TEMP1`, `BRK_TEMP2`, `BRK_TEMP3`, `BRK_TEMP4` FROM 
                   (SELECT @ROWNUM:=@ROWNUM+1 AS ROWNUM, T.`DATE_TIME`, T.`BRK_TEMP1`, T.`BRK_TEMP2`, T.`BRK_TEMP3`, T.`BRK_TEMP4` FROM (SELECT @ROWNUM:=0) R, `PHM_HEALTHTRENDS4WHEEL` T) AS DATA 
                WHERE (DATA.ROWNUM % 4 = 0) order by `DATE_TIME` ;";

        //带参数条件查询
        $RST = $this->db->query($sql)->getResultArray();

        //输出数组
        foreach ($RST as $RST_ITEM) {
            $BRK1[] = array(
                $RST_ITEM['DATE_TIME'], intval($RST_ITEM['BRK_TEMP1'])
            );
            $BRK2[] = array(
                $RST_ITEM['DATE_TIME'], intval($RST_ITEM['BRK_TEMP2'])
            );
            $BRK3[] = array(
                $RST_ITEM['DATE_TIME'], intval($RST_ITEM['BRK_TEMP3'])
            );
            $BRK4[] = array(
                $RST_ITEM['DATE_TIME'], intval($RST_ITEM['BRK_TEMP4'])
            );
        };
        $ARR = array(
            $BRK1,
            $BRK2,
            $BRK3,
            $BRK4,
        );
        return $ARR;
    }
}